- /* srmeffig.cpp by K.Tsuru */
- // function ID = 008
- /**************************************
- RealSize class
- 1.destructor
- 2.Set the numbers of effective figures.
- ***************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
-
- RealSize::~RealSize(){
- if(size[0]) Restore(); // restore effective figures
- }
- uint RealSize::SetEffFig(uint fig, int proper){
- if(proper & PREF_SPEED) preferSpeed = true;
- if(!fig){ //It restores to the previous values.
- if(size[0] == 0) SetError(SET_EFF_FIG, "No data", 8);
- Restore();
- return effFigures;
- }
- //It saves present figures and size.
- if(size[0] != 0) SetError(SET_EFF_FIG, "Save data twice", 8);
- Save();
- if(effFigures == fig) return effFigures;
-
- //necessary size including hidden figures and figure[0]
- uint oldsz = effFigures + hidden + 1u, hdn;
- int decr_fig = 0;
- //When the number of hidden figures increases by adding hidden figures
- //it decreases by "decr_fig" figures.
- hidden = HiddenSize(fig);
- hdn = HiddenSize(fig+hidden+1u);
- if( (hdn > hidden) && !(proper & TEMP_EXTEND)){
- fig -= hdn; decr_fig = (int)hdn;
- }
- uint sz = ceilpow2(fig);
- while(decr_fig && (fig + hidden + 1u < sz)){
- //It restores the decreased figures as much as possible.
- fig++; decr_fig--;
- }
- if( sz <= minArraySize ){
- sz = 2u*minArraySize;
- effFigures = sz - hidden -1u;
- } else if( sz > MaxArraySize() ){
- if(!(proper & TEMP_EXTEND)) SetError(SET_EFF_FIG, "Effective figures is too large.", -8);
- //Because there is functions which temporally increases the effective figures
- //it decreases the effective figures a little.
- sz = MaxArraySize() - 8u;
- effFigures = sz - hidden -1u;
- proper = 0;
- } else effFigures = fig;
- /****************************************************************
- It provides a proper value of effFigures which is efficient for
- FFT multiplication and memory.It is desirable to adopt the value
- of CurrentMaxSize()(=effFigures+hidden+1u) as power of two because
- the upper part is taken one figure larger in DDMult().
- example :
- sz = CurrentMaxSize() = 128, effFigures = 125, hidden = 2.
- Excluding the first zero (128-1)/2+1=64(= 2^6) figures are passed
- to LLMult().
- *****************************************************************/
- sz = effFigures + hidden +1u;
- if(proper & PROPER){
- sz = ceilpow2(sz);
- hidden = HiddenSize(sz- hidden -1u);
- effFigures = sz - hidden -1u;
- }
- /*
- In the fixed point mode(reduceMaxSize == DISABLE, using the doubling effective
- figures method etc) it changes the value of maxSize when the present size is
- greater than the previous one only.
- */
- if( (reduceMaxSize == ENABLE) || (sz > oldsz) ) SetMaxSize();
-
- return effFigures;
- }
smrsteff.cpp : last modifiled at 2017/03/06 16:01:25(2,716 bytes)
created at 2016/04/11 11:36:47
The creation time of this html file is 2017/10/27 10:59:17 (Fri Oct 27 10:59:17 2017).